package com.hyperchain.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hyperchain.entity.DbAccount;
import com.hyperchain.entity.vo.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
 * (Account)表数据库访问层
 *
 * @author makejava
 * @since 2023-08-09 10:12:40
 */
@Mapper
public interface AccountMapper extends BaseMapper<DbAccount> {

    @Select("select accrole.account_id , dr.role_name , dr.role_key , dm.permission from\n" +
            "db_account acc\n" +
            "inner join \n" +
            "db_account_role accrole on accrole.account_id = acc.id and acc.id = #{accountId}\n" +
            "left join\n" +
            "db_role dr on dr.role_id = accrole.role_id \n" +
            "left join \n" +
            "db_role_menu drm on drm.role_id = accrole.role_id \n" +
            "left JOIN \n" +
            "db_menu dm on dm.menu_id = drm.menu_id")
    List<UserInfo> getUserRoleAndPermission(Integer accountId);
}
